/**
 * Created by koudaiwang on 2017/7/11.
 */


new Vue({
    el: '#form',
    data: {
        title: '',
        content: '',
        type: '1',
        options: [
            { text: 'BTC', value: '1' },
            { text: 'ETC', value: '2' },
            { text: 'LTC', value: '3' }
        ]
    },
    methods: {
        addnews: function () {
            var content = window.document.getElementById('ts').value;
            var paras = {
                title: this.title,
                type: this.type,
                content: content,
                deviceType: 'web',
                username: localStorage.username,
                sessionID: localStorage.sessionID
            };
            this.$http.post('/addNews', paras)
                .then(function (response) {
                    console.log(response)
                    if (response.body.status == '1') {
                       window.alert(response.body.msg);
                        window.location.href="./addnews.html";
                    } else {
                        window.document.getElementById('error').innerHTML = '错误：' + response.body.msg;
                    }
                }, function (response) {
                    console.log(response);
                });
        }
    }

})